package com.cs.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.listener.ReadListener;
import com.cs.entity.Department;
import com.cs.mapper.DepartmentMapper;

import java.util.Map;

public class ExcelListener extends AnalysisEventListener<Department> {

    private DepartmentMapper departmentMapper;

    public ExcelListener(DepartmentMapper departmentMapper) {
        this.departmentMapper = departmentMapper;
    }

    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头信息"+headMap);
    }

    @Override
    //从第二行读取
    public void invoke(Department department, AnalysisContext analysisContext) {
        departmentMapper.insert(department);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}